<?php
/*  Copyright 2011  Jacob Brunson  (email : wp-jacob.gpl.license@jacobbrunson.com )

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

if (!isset($album)) die("This page cannot be accessed directly");

?><html>
<head>
<title><?php echo $album->getTitle(); ?></title>
<script type="text/javascript" 
    src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<style>
body {
    background-color: #aaa;    
    padding: 0;
    margin: 0;
}

div.photopreview, div.directorypreview {
    float:left;
    border:1px solid black;
    width:180px;
    height:180px;
    align:center;
    margin:8px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    background-color: #f4f4f4;
    -moz-box-shadow: 0 0 10px #888;
    -webkit-box-shadow: 0 0 10px #888;
    box-shadow: 0 0 10px #888;
    text-align: center;
    padding-top: 15px; 
    overflow: hidden;
}

div.photopreview img {
    -moz-box-shadow: 2px 2px 8px #888;
    -webkit-box-shadow: 2px 2px 8px #888;
    box-shadow: 2px 2px 8px #888;
    border: none;
}

h1 {
    width: 100%;
    background-color: white; 
    margin: 0;
    padding: .3em; 
    margin-bottom: .5em;
    border-bottom: 7px solid #bbb;
}

</style>
<script type="text/javascript">
function start() {
    $$('div.photopreview').observe('mouseover', function(event) {
        alert('clicked on the div');
        //event.findElement('a').fire('click');
    });
}
</script>
</head>
<body onload="start()">
<h1><?php echo $album->getTitle(); ?></h1>
<?php $sub_obj = $album->getNextSubAlbum(); while ($sub_obj) : ?>
<?php if ($sub_obj == false) break; ?>
<div class="directorypreview">
    <strong>Directory:</strong><br/>
    <a href="<?php echo Site::getURL('dir', $source_id, $sub_obj->getId());?>">
        <?php echo $sub_obj->getTitle(); ?>
    </a>
</div>
<?php $sub_obj = $album->getNextSubAlbum(); endwhile; ?>

<?php $photo_obj = $album->getNextPhoto(); while ($photo_obj) : ?>
<?php if ($photo_obj == false) break; ?>
<div class="photopreview">
    <a href="<?php echo Site::getURL('photo', $source_id, $photo_obj->getId());?>">
        <?php
        if ($photo_obj instanceof HttpPhoto_I) {
            $url = $photo_obj->getURL($site->thumbnail_size);
        } else if ($photo_obj instanceof UriPhoto_I) {
            $url = Site::getResizeURL($source_id, $photo_obj->getId(), $site->thumbnail_size);
        }
        ?>
        <img src="<?php echo $url; ?>"/><br/>
        <?php echo $photo_obj->getTitle(); ?>
    </a>
</div>
<?php $photo_obj = $album->getNextPhoto(); endwhile; ?>


</body>
</html>